package com.jigsawapp.movies.api;

import android.util.Log;

import com.jigsawapp.movies.common.StringUtils;
import com.kymjs.rxvolley.client.HttpCallback;
import com.kymjs.rxvolley.client.HttpParams;

/**
 * Created by jigsaw on 2016/3/11.
 * Email: fadeblack307@163.com
 */
public class MoviesApi {
    public final static String HOST = "192.168.1.103:8080/";
    public final static String API_VERSION = "api/v1/";
    public final static String HTTP = "http://";
    public final static String BASE_URL = HTTP + HOST + API_VERSION;
    public final static String MOVIES_URL = "http://192.168.1.102:8080/movies/";
    public final static String MOVIES_IMG = "http://192.168.1.102:8080/images/";


    public static void login(String account, String password, HttpCallback handler) {
        HttpParams params = AsyncHttpHelp.getHttpParams();
        params.put("email", account);
        params.put("password", password);
        AsyncHttpHelp.post(BASE_URL + "login", params, handler);
    }

    public static void register(String email, String username, String password, HttpCallback handler) {
        HttpParams params = AsyncHttpHelp.getHttpParams();
        params.put("email", email);
        params.put("username", username);
        params.put("password", password);
        AsyncHttpHelp.post(BASE_URL + "register", params, handler);
    }

    public static void moviesIndex(String pagenum, String pagesize, HttpCallback handler) {
        HttpParams params = AsyncHttpHelp.getHttpParams();
        AsyncHttpHelp.get(StringUtils.buildMoviesUrl(pagenum, pagesize), handler);
    }
}
